add-on conf files#3000
Conversation
|
I added inline javascript to this template, just so it can be tested that the functionality works. I will need some guidance with how to move the javascript somewhere else. |
|
The place to put a javascript file for this would be in |
|
OK, thanks. This is ready to examine now. |
The JavaScript needs to not attempt to do anything with the
`add_on_conf` select if it is not present in the page, as that causes
errors. For instance if the `$webworkDirs{addOnConf}` directory is not
present, or is empty.
With modern JavaScript, don't use the array `forEach` method unless it
gives a convenient and brief one liner. Generally prefer a `for of`
loop as it is more readable. Another advantage is that `for of` loops
work on `HTMLCollection`s and `forEach` does not. The result of a
`querySelectorAll` call or the `children` of an `Element` are
`HTMLCollection`s, and so a `for of` loop works directly, while
`Array.from` is needed to use `forEach`. This is a minor inefficiency in
this case, but that does require constructing an array from the
`HTMLCollection`.
I rewrote the `writeCourseConf` POD to clarify its usage some with the
new optional parameter.
In the `writeCourseConf` method, it should be checked that the
`$addOnConf` variable is an array reference, and not that it is not
equal to the empty string. Any numeric value or non empty string is not
equal to the empty string and would cause an error if `$addOnConf` is
set to any of those. The check should be that `ref $addOnConf eq 'ARRAY'`.
That is the only condition that guarantees an error will not occur and
that the value of the variable will work inside the conditional block.
Minor cleanup in the `templates/ContentGenerator/CourseAdmin/add_course_form.html.ep`
file. There is no need to copy the value of `$ce->{webworkDirs}{addOnConf}`
to a local variable. Particularly since that can be used directly even
in string interpolation.
drgrice1
left a comment
There was a problem hiding this comment.
I think this generally looks good. I am going to add a pull request with some minor clean up and issue fixes. The things in the pull request are explained there rather than duplicating the comments in this review.
One thing that I noticed and that I did not address in the pull request to this branch is that the JavaScript handling of the add_on_conf select does result in some odd behavior if Ctrl or Shift are used in combination with the array keys, or if the mouse is used to click and drag to select options. I suppose it is fine for this case though.
Suggested clean up and minor issue fixes.
|
Thanks for the changes. And I hadn't thought to try keyboard use of that select. It seems that if you are trying to make a legal selection, keyboard use works though, so I'm not too concerned. I only see the weirdness if I try to make an illegal selection. |

This allows for there to be a folder
webwork2/conf/addon/(or some other name, overridden inlocalOverrides.conf) where you can store.conffiles. This has to do with #2999.When adding a new course from the admin course, you can select one or more of these config files to be included at the end of the new course's
course.conffile. If the new course is copying acourse.conffile from some other course, nothing happens with.conffiles from theaddonfolder.If there is no
addonfolder, or if it has no.conffiles in it, there is no change in the Add Course page. Otherwise, the checkbox for copying an old course'scourse.conffile is gone, and there is one select. The select has three optgroups:course.conffile. This is also what will happen if the form is submitted with no selection made.course.conffile from the indicated older course..conffiles from theaddonfolder.The select allows multiple selections. This needs one more thing where I need javascript help from @drgrice1. If the option from the first or second optgroup is selected, all other options need to be de-selected. Googling, I see how to do this with javascript. But I'm not sure where to build that javascript properly for its use here. That is, I'm not sure what I should do instead of writing inline script.